package org.goyo.main.domain.entity.storage;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import org.goyo.main.domain.entity.BaseObject;
import org.goyo.main.domain.entity.base.BaseUnitMeasure;
import org.goyo.main.domain.entity.base.Material;
/**
 * 组合销售
 * 
 * @author chenchuan
 * 2014年12月7日
 */
@Entity
public class GroupMaterial  extends BaseObject  implements Serializable {

	private static final long serialVersionUID = 1L;
	//单据编号前缀
	public static final String BIZTYPE = "ZHXS";
	/**
	 * 商品
	 */
	@ManyToOne
	@JoinColumn(name="materialId")
	private Material material;
	/**
	 * 商品名称
	 */
	@Column
	private String materialName;
	/**
	 * 商品规格型号	
	 */
	@Column
	private String materialStandard;
	/**
	 * 计量单位	
	 */
	@ManyToOne
	@JoinColumn(name="jilUnitId")
	private BaseUnitMeasure jilUnit;
	/**
	 * 分录
	 */
	@OneToMany(cascade={CascadeType.ALL})
	@JoinColumn(name="parent_id")
	private List<GroupMaterialEntry> entrys = new ArrayList<GroupMaterialEntry>();
	
	/**
	 * 组合数量
	 */
	@Column
	private double groupQty = 0;
	
	/**
	 * 辅助计量单位	
	 */
	@ManyToOne
	@JoinColumn(name="fjilUnitId")
	private BaseUnitMeasure fjilUnit;
	
	/**
	 * 组合数量
	 */
	@Column
	private double fgroupQty = 0;
	
	/**
	 * 业务类型
	 */
	@Column
	private String bizType;

	public Material getMaterial() {
		return material;
	}

	public void setMaterial(Material material) {
	  if(material != null &&("".equals(material.getUuid()) || material.getUuid()==null))
	      this.material = null;
	    else
	        this.material = material;
	}

	public List<GroupMaterialEntry> getEntrys() {
		return entrys;
	}

	public void setEntrys(List<GroupMaterialEntry> entrys) {
		this.entrys = entrys;
	}

	public double getGroupQty() {
		return groupQty;
	}

	public void setGroupQty(double groupQty) {
		this.groupQty = groupQty;
	}

	public String getBizType() {
		return bizType;
	}

	public void setBizType(String bizType) {
		this.bizType = bizType;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public String getMaterialName() {
		return materialName;
	}

	public void setMaterialName(String materialName) {
		this.materialName = materialName;
	}

	public String getMaterialStandard() {
		return materialStandard;
	}

	public void setMaterialStandard(String materialStandard) {
		this.materialStandard = materialStandard;
	}

	public BaseUnitMeasure getJilUnit() {
		return jilUnit;
	}

	public void setJilUnit(BaseUnitMeasure jilUnit) {
	  if(jilUnit != null &&("".equals(jilUnit.getUuid()) || jilUnit.getUuid()==null))
        this.jilUnit = null;
      else
          this.jilUnit = jilUnit;
	}

	public BaseUnitMeasure getFjilUnit() {
		return fjilUnit;
	}

	public void setFjilUnit(BaseUnitMeasure fjilUnit) {
	  if(fjilUnit != null &&("".equals(fjilUnit.getUuid()) || fjilUnit.getUuid()==null))
        this.fjilUnit = null;
      else
          this.fjilUnit = fjilUnit;
	}

	public double getFgroupQty() {
		return fgroupQty;
	}

	public void setFgroupQty(double fgroupQty) {
		this.fgroupQty = fgroupQty;
	}
	
}
